<template>
<div v-loading="loading" element-loading-text="加载中，请稍候" class=''>
  {{tips}}
</div>
</template>

<script>
import API from "@/api/login";
export default {
  components: {},
  data() {
    return {
      loading: false,
      tips: "测试Promise.all"
    };
  },
  mounted() {
    this.loading = true;
    const pAll = Promise.all([this.login1(), this.login2(), this.login3()]);
    pAll
      .then(
        values => {
          this.$message.success("Promise.all成功！");
        },
        reason => {
          this.$message.error("Promise.all失败！");
        }
      )
      .finally(() => {
        this.loading = false;
      });
  },
  //方法集合
  methods: {
    login1() {
      return API.login1("test")
        .then(res => {})
        .catch(e => {
          return Promise.reject(e);
        });
    },
    login2() {
      return API.login2("test")
        .then(res => {})
        .catch(e => {
          return Promise.reject(e);
        });
    },
    login3() {
      return API.login3("test")
        .then(res => {})
        .catch(e => {
          return Promise.reject(e);
        });
    }
  }
};
</script>

<style lang='scss' scoped>
</style>
